package com.gz.spring.component;

import com.gz.spring.annotation.Autowired;
import com.gz.spring.annotation.Component;
import com.gz.spring.annotation.Scope;
import com.gz.spring.processor.InitializingBean;

//如果指定了value，那么在注入容器是，以指定的为准，如果没有指定，则以首字母小写monsterService
@Component //自定义的注解
@Scope(value="prototype")
public class MonsterService implements InitializingBean {
    //这里用自己的Autowired来修饰属性
    //通过容器来完成依赖注入
    @Autowired
    private MonsterDao monsterDao;

    public void m1(){
        monsterDao.sayHello();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("MonsterService 初始化方法被调用");
    }
}
